package cn.stylefeng.guns.modular.ercomment.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.erlove.model.param.ErLoveParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.ercomment.service.ErCommentService;
import cn.stylefeng.guns.modular.ercomment.model.param.ErCommentParam;

import javax.annotation.Resource;

/**
 * 评论 控制器
 *
 * @author: wpk
 * @date: 2021/06/25 15:19
 */
@RestController
public class ErCommentController {

    @Resource
    private ErCommentService erCommentService;

    /**
     * 分页查询评论
     *
     * @author wpk
     * @date 2021/06/25 15:19
     */
    @GetMapping("/erComment/pageComment")
    @BusinessLog(title = "评论_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(ErCommentParam erCommentParam) {
        return new SuccessResponseData(erCommentService.pageComment(erCommentParam));
    }

    /**
     * 获取全部评论
     *
     * @author wpk
     * @date 2021/06/25 15:19
     */
    @GetMapping("/erComment/list")
    @BusinessLog(title = "评论_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(ErCommentParam erCommentParam) {
        return new SuccessResponseData(erCommentService.list(erCommentParam));
    }

    /**
     * 查看详情评论
     *
     * @author wpk
     * @date 2021/06/25 15:19
     */
    @GetMapping("/erComment/detail")
    @BusinessLog(title = "评论_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(ErCommentParam.detail.class) ErCommentParam erCommentParam) {
        return new SuccessResponseData(erCommentService.detail(erCommentParam));
    }

    /**
     * 添加评论
     *
     * @author wpk
     * @date 2021/06/25 15:19
     */
    @PostMapping("/erComment/add")
    @BusinessLog(title = "评论_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(ErCommentParam.add.class) ErCommentParam erCommentParam) {
        return new SuccessResponseData(erCommentService.add(erCommentParam));
    }

    /**
     * 删除评论
     *
     * @author wpk
     * @date 2021/06/25 15:19
     */
    @PostMapping("/erComment/delete")
    @BusinessLog(title = "评论_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(ErCommentParam.delete.class) ErCommentParam erCommentParam) {
        erCommentService.delete(erCommentParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑评论
     *
     * @author wpk
     * @date 2021/06/25 15:19
     */
    @PostMapping("/erComment/edit")
    @BusinessLog(title = "评论_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(ErCommentParam.edit.class) ErCommentParam erCommentParam) {
        erCommentService.edit(erCommentParam);
        return new SuccessResponseData();
    }
    /**
     * 添加点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @PostMapping("/erComment/love")
    @BusinessLog(title = "点赞_增加_取消")
    public ResponseData love(@RequestBody ErCommentParam erCommentParam) {
        return new SuccessResponseData(erCommentService.love(erCommentParam));
    }
    /**
     * 点赞状态
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @PostMapping("/erComment/showLoveState")
    @BusinessLog(title = "点赞状态")
    public ResponseData showLoveState(@RequestBody ErCommentParam erCommentParam) {
        return new SuccessResponseData(erCommentService.showLoveState(erCommentParam));
    }

}
